package com.wyw.hemerocallis.rocket;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.wyw.hemerocallis.vo.WywMessage;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

/**
 * 指定消费带有tag的消息，且消费的是Java Pojo
 *
 * @author Mr Wu    yewen.wu.china@gmail.com
 * <p>
 * Update History:
 * Author        Time            Content
 */
@Slf4j
@Component
@RocketMQMessageListener(
        topic = "wyw-study-rocketmq",
        consumerGroup = "wyw-springboot-rocketmq-tag-object",
        selectorExpression = "wyw"  //根据tag过滤
)
public class RocketMQConsumerObject implements RocketMQListener<WywMessage> {
    @Override
    public void onMessage(WywMessage message) {
        log.info("consume message in RocketMQConsumerObject: [{}]",
                JSON.toJSONString(message, SerializerFeature.IgnoreNonFieldGetter));
        // so something
    }
}
